package com.leemz.tgs.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.leemz.tgs.domain.Expense;
import com.leemz.tgs.mapper.ExpenseMapper;
import com.leemz.tgs.service.ExpenseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ExpenseServiceImpl implements ExpenseService {

    @Autowired
    private ExpenseMapper expenseMapper;

    @Override
    public PageInfo<Expense> listByPage(int currentPage, int pageSize, Map<String, Object> params) {
        PageHelper.startPage(currentPage, pageSize);
        List<Expense> list = expenseMapper.findAll(params);
        PageInfo<Expense> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void insert(Expense expense) {
        expenseMapper.insert(expense);
    }

    @Override
    public void delete(Integer id) {
        expenseMapper.delete(id);
    }
}